package api

import (
	"2212b/awesomeProject18/api/handler"
	"2212b/awesomeProject18/consts"
	"github.com/gin-gonic/gin"
	jwt "github.com/golangblogs/gojwt"
)

func ToadRouter(r *gin.Engine) {
	api := r.Group("api")
	{
		user := api.Group("user")
		{
			user.POST("/register", handler.Register)
			user.POST("/login", handler.Login)

		}
		friend := api.Group("friend")
		{
			friend.Use(jwt.JWTAuth(consts.JWT_KEY))
			friend.POST("/add", handler.AddFriend)
			friend.POST("/reply", handler.ReplyFriend)
			friend.POST("/remove", handler.RemoveFriend)
		}
		chat := api.Group("chat")
		{
			chat.Use(jwt.JWTAuth(consts.JWT_KEY))
			chat.GET("/ws", handler.Chat)
		}
	}
}
